package com.apes.fn.ssm.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.product.model.Brand;
import com.apes.scm.masterdata.stock.model.Location;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @ClassName : BrandPriority
 * @Description : 品牌优先级
 * @Author : WSl
 * @Date: 2022-6-21 10:37
 */

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = BrandPriority.CONST_TABLE_NAME,indexes = {@Index(columnList = "location_id,fitting_Name_id,brand_id", unique = true)})
public class BrandPriority extends Model {

    public final static String CONST_TABLE_NAME = "mas_brand_priority";

    @Id
    @Column(name = "id", length = 10)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "品牌优先级")
    @Comment("编码")
    private String id;


    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "location_id", referencedColumnName = "id", nullable = false)
    @Comment("仓库库区")
    private Location location;


    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fitting_Name_id", referencedColumnName = "id", nullable = false)
    @Comment("组合配件名称")
    private FittingMessage fittingName;


    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "brand_id", referencedColumnName = "id", nullable = false)
    @Comment("品牌")
    private Brand brand;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "priority", referencedColumnName = "id")
    @Comment("优先级")
    private Enumeration priority;

    @Column(name = "valid", nullable = false, columnDefinition = "number(1,0) default 0")
    @Comment("有效")//仓库测算标记
    private boolean valid = true;


}
